<template>
    <div>
        <a-button type="primary" @click="addlist">新增分类</a-button>
        <a-modal v-model:visible="addcate" :title="title" @ok="hd">
            <a-form
    :model="formState"
    name="basic"
    :label-col="{ span: 8 }"
    :wrapper-col="{ span: 16 }"
    autocomplete="off"
   
  >
    <a-form-item
      :label="lable"
      name="name"
      :rules="[{ required: true, message: '请输入分类名' }]"
    >
      <a-input v-model:value="formState.name" />
    </a-form-item>



  
  </a-form>
    </a-modal>
    </div>
    <a-table :columns="columns" :data-source="data">
      <template #headerCell="{ column }">
        <template v-if="column.key === 'name'">
          <span>
            <smile-outlined />
           分类
          </span>
        </template>
      </template>
  
      <template #bodyCell="{ column, record }">
        <template v-if="column.key === 'name'">
          <a>
            {{ record.name }}
          </a>
        </template>
  
        <template v-else-if="column.key === 'action'">
   
           
          <span>
            <a @click="showDeleteConfirm(record)">删除</a>
         
        </span>
            <span style="margin: 0 10px">|</span>
            <span @click="dj(record)">
            <a>更改</a>
            <!-- <div id="components-modal-demo-position">
  
  <a-modal
    v-model:visible="modal1Visible"
    title="更改分类"
    style="top: 20px"
    @ok="setModal1Visible(record)"
  >
  <a-form
  :model="State"
  name="basic"
  :label-col="{ span: 8 }"
  :wrapper-col="{ span: 16 }"
  autocomplete="off"
 
>
  <a-form-item
    label="更改分类"
    name="name"
    :rules="[{ required: true, message: '请输入分类名' }]"
  >
    <a-input v-model:value="State.name" />
  </a-form-item>




</a-form>
   
   
  </a-modal>


</div>  -->
        </span>

        </template>
      </template>
    </a-table>
  
  </template>
  <script lang="ts" setup>
  import {zdygz,columns,} from './list'
import {lable,addcate,formState,hd,addlist,showModal,dj,title} from './addlist'    //增加
import {showDeleteConfirm} from './removelist'            //删除
import {updateList} from '@/api/cateList/list'
import { createVNode, defineComponent,ref ,reactive} from 'vue';
import { message, Modal } from 'ant-design-vue';
import type { string } from '_vue-types@3.0.2@vue-types';
  let {data} = zdygz()   //数据




//     const setModal1Visible = (e:any) => {

//       console.log(e)
//       let {_id} = e
//       let {name} = State
//     updateList({
//   cate_id:_id,
//   cate_name:name
// }).then((res:any)=>{
//   console.log(res)
//   if(res.code==0){
//     message.success(res.msg)
//      modal1Visible.value=false
//   }else{
//     message.warning(res.msg)
//   }
// })
//       console.log(State)
//     };









function update(e:any){
console.log(e)
let {name,_id} = e
updateList({
  cate_id:_id,
  cate_name:name
}).then((res)=>{
  console.log(res)
})
}

//  let {hd}=succes()   //增加





 


  </script>
  <style scoped>
  ::v-deep .ant-col-8{
  flex: 0.2;
} 


::v-deep .ant-modal-wrap {
    z-index: 1000;
    top: 500px;
}
::v-deep .ant-modal{
  color: red;
}

</style>
  
  